import jwt from 'jsonwebtoken'
import { expressjwt } from 'express-jwt'


const secretKey = "测试密码";
// 生成token
export const getToken = function(user={}){
    return jwt.sign(user,secretKey,{
        expiresIn:"24h",  // 可以修改为：1h, 30m, 7d, 30d 等
        algorithm:'HS256'
    })
}

// 验证token授权判断
export const auth = function(){
    return expressjwt({
        secret:secretKey,
        algorithms:['HS256']
    })
}